package com.lyh.web.controller.pay;

import com.lyh.common.annotation.Log;
import com.lyh.common.core.controller.BaseController;
import com.lyh.common.core.domain.AjaxResult;
import com.lyh.common.enums.BusinessType;
import com.lyh.system.domain.req.MemberPurchasAuditReq;
import com.lyh.system.domain.req.WxPrepareReq;
import com.lyh.system.domain.resp.WxPayInfoResp;
import com.lyh.system.service.IPayService;
import com.wechat.pay.contrib.apache.httpclient.auth.ScheduledUpdateCertificatesVerifier;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;


@RestController
@RequestMapping("/pay/wx")
@Api( value = "微信支付",description = "微信支付")
public class WxPayController  extends BaseController {

    @Autowired
    private IPayService payService;

    @ApiOperation("微信-app微信下单准备")
    @PostMapping("/getPrepayId")
    @Log(title = "微信-app微信下单准备", businessType = BusinessType.INSERT)
    public AjaxResult getPrepayId(@Validated @RequestBody WxPrepareReq req) {
        return AjaxResult.success(payService.getPrepayId(req));
    }

    @ApiOperation("微信-支付通知")
    @PostMapping("/wehcatPayCallback")
    @Log(title = "微信-支付通知", businessType = BusinessType.INSERT)
    public AjaxResult wehcatPayCallback(HttpServletRequest request,
                                                             HttpServletResponse response) {
        payService.wehcatPayCallback(request, response);
        return AjaxResult.success();
    }


    }
